Skip to content

Conversation

@sayakpaul
Copy link
Member

What does this PR do?

To confirm, run: pytest tests/lora/test_lora_layers_sd.py::StableDiffusionLoRATests::test_integration_move_lora_cpu after replacing "runwayml/stable-diffusion-v1-5" with "Jiali/stable-diffusion-1.5" in the tests/lora/test_lora_layers_sd.py file.

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Member

@BenjaminBossan BenjaminBossan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, nice catch, LGTM.

@yiyixuxu
Copy link
Collaborator

tests/lora/test_lora_layers_sd.py::StableDiffusionLoRATests::test_integration_move_lora_cpu after replacing "runwayml/stable-diffusion-v1-5" with "Jiali/stable-diffusion-1.5" in the tests/lora/test_lora_layers_sd.py file.

is this test supposed to fail at main right now? (after replace the checkpoint)?

@sayakpaul
Copy link
Member Author

Yes, it'd fail with the replacement. However, previously, it wasn't the case. @BenjaminBossan I wonder if something changed on the peft side?

@BenjaminBossan
Copy link
Member

Yes, it'd fail with the replacement. However, previously, it wasn't the case. @BenjaminBossan I wonder if something changed on the peft side?

Sorry, I'm missing some context. Under what circumstances is the test failing? Are there logs?

@sayakpaul
Copy link
Member Author

Sorry, what I meant is that the test tests/lora/test_lora_layers_sd.py::StableDiffusionLoRATests::test_integration_move_lora_cpu was passing without this PR. But currently it fails (of course we have to replace the Runway SD v1.5 checkpoint with "Jiali/stable-diffusion-1.5" as Runway has taken it down).

The failure:

        # We will offload the first adapter in CPU and check if the offloading
        # has been performed correctly
>       pipe.set_lora_device(["adapter-1"], "cpu")

tests/lora/test_lora_layers_sd.py:126: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
src/diffusers/loaders/lora_base.py:702: in set_lora_device
    module.lora_magnitude_vector[adapter_name] = module.lora_magnitude_vector[
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = ModuleDict(), key = 'adapter-1'

    @_copy_to_script_wrapper
    def __getitem__(self, key: str) -> Module:
>       return self._modules[key]
E       KeyError: 'adapter-1'

But with peft=0.11.0 the test successfully passes. Hopefully, this is fully clear now?

@BenjaminBossan
Copy link
Member

I see, thanks for the extra info. Indeed, this PR broke the test: huggingface/peft#1806. It's been merged for quite some time, not sure why we didn't notice earlier, is it because the SD model was removed? Anyway, the fix in this PR is correct given the change in PEFT.

Copy link
Collaborator

@yiyixuxu yiyixuxu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@sayakpaul sayakpaul merged commit 6dc6486 into main Sep 13, 2024
17 of 18 checks passed
@sayakpaul sayakpaul deleted the fix-adapter-check branch September 13, 2024 02:01
sayakpaul added a commit that referenced this pull request Dec 23, 2024
fix adapter movement when using DoRA.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants